<template>
  <el-table :data="tableData" style="width: 100%">
    <el-table-column label="用户名" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.name }}</span>
      </template>
    </el-table-column>
    <el-table-column label="昵称" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.nickName }}</span>
      </template>
    </el-table-column>
    <el-table-column label="邮箱" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.email }}</span>
      </template>
    </el-table-column>
    <el-table-column label="密码" width="180">
      <template slot-scope="scope">
        <span style="margin-left: 10px">{{ scope.row.password }}</span>
      </template>
    </el-table-column>
    <el-table-column label="操作">
      <template slot-scope="scope">
        <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
          >编辑</el-button
        >
        <el-button
          size="mini"
          type="danger"
          @click="handleDelete(scope.$index, scope.row)"
          >删除</el-button
        >
      </template>
    </el-table-column>
  </el-table>
</template>
  
<script>
export default {
  data() {
    return {
      tableData: [
        {
          name: "wxh",
          nickName: "王小虎",
          email: "wxh@126.com",
          password: "123456",
        },
        {
          name: "wxh",
          nickName: "王小虎",
          email: "wxh@126.com",
          password: "123456",
        },
      ],
    };
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
  },
  mounted() {
    console.log('dddddddddddddddddd')
    let that = this
    this.$http.get("/users").then(function(res){
      that.tableData = res.data
    })
   
  },
};
</script>